home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / serial / callback.001 / callback~ / callback / build next >
Text File  |  1996-08-02  |  5KB  |  215 lines

  1. #!/usr/local/bin/icmake -qt /tmp/callback
  2.  
  3. #include "configure.h"
  4.  
  5. usage()
  6. {
  7.     printf
  8.     (
  9.         "\n"
  10.         "Icmake callback build script\n"
  11.         "Usage:\n"
  12.         "   build arg\n"
  13.         "Where arg:\n"
  14.         "   clean            - to remove .o and .a files and binaries\n"
  15.         "   dist             - to make a distribution (internal use only)\n"
  16.         "   install callback - to install for callback in /conf/callback\n"
  17.         "   install dial-in  - to install for dial-in in /conf/callback\n"
  18.         "   man              - to install gzipped manpages in var/man/cat{1,4}\n"
  19.         "   progs            - to build the programs and library\n"
  20.         "   tar              - 'build progs' and tar the callback directories\n"
  21.     );
  22.  
  23.     exit (1);
  24. }
  25.  
  26. void refresh()
  27. {
  28.     system("rm -f cb/cb login/cblogin mgetty/cbmgetty");
  29. }
  30.  
  31. void building(string dir)
  32. {
  33.     printf("\n"
  34.            "Changing to directory '", dir, "'\n");
  35.  
  36.     chdir(dir);
  37.     system("build");
  38.     chdir("..");
  39. }
  40.  
  41. void prog(string dir, string program)
  42. {
  43.     printf("\n"
  44.            "Changing to directory '", dir, "'\n");
  45.  
  46.     chdir(dir);
  47.  
  48.     if ("../lib/librss.a" younger program)
  49.         exec("rm", "-f", program);
  50.  
  51.     system("build");
  52.     chdir("..");
  53. }
  54.  
  55. void testconfigure(string source)
  56. {
  57.     if ("configure.h" younger source)
  58.         exec("touch", source);
  59. }
  60.  
  61. void progs()
  62. {   
  63.     if ("lib/version.c" younger "lib/librss.a")
  64.         refresh();
  65.     testconfigure("lib/config/configdata.c");
  66.     testconfigure("lib/dbase/dbasedata.c");
  67.     testconfigure("lib/parser/parsesetupfile.c");
  68.     testconfigure("lib/process/killinit.c");
  69.     testconfigure("lib/process/modemrespawn.c");
  70.     testconfigure("lib/log/logdata.c");
  71.                    
  72.     building("lib");
  73.     prog("cb", "cb");
  74.     prog("mgetty", "cbmgetty");
  75.     prog("login", "cblogin");
  76. }
  77.  
  78. void tarring()
  79. {
  80.     printf("\n"
  81.            "Tarring all information\n");
  82.  
  83.     chdir("..");
  84.        
  85.     system("tar czvf src-callback-`grep version\\\\\\[\\\\\\\] "
  86.             "callback/version.c | cut -f2 -d\\\"`.tar.gz callback");
  87. }
  88.              
  89. void tar()
  90. {
  91.     printf("\n"
  92.            "Building library and programs\n");
  93.            
  94.     progs();
  95.     
  96.     tarring();
  97. }
  98.  
  99. void clean()
  100. {
  101.     system("rm -f cb/cb login/cblogin mgetty/cbmgetty lib/librss.a */o/*"
  102.            " */*/o/*");
  103. }
  104.                 
  105. void dist()
  106. {
  107.     printf("\n"
  108.            "Making a distribution tar.gz\n");
  109.  
  110.     tar();
  111.  
  112.     chdir("callback");
  113.  
  114.     system("cp cb/cb login/cblogin mgetty/cbmgetty bin");
  115.  
  116.     clean();
  117.        
  118.     chdir("..");
  119.  
  120.     system("tar czvf callback-`grep version\\\\\\[\\\\\\\] "
  121.             "callback/version.c | cut -f2 -d\\\"`.tar.gz "
  122.             "callback/[A-Z]* "
  123.             "callback/{build,callback.lsm,*.h} "
  124.             "callback/{bin,cb,examples,lib,login,man,mgetty} "
  125.         );
  126.  
  127.     system("tar xzf src-callback-`grep version\\\\\\[\\\\\\\] "
  128.             "callback/version.c | cut -f2 -d\\\"`.tar.gz");
  129. }
  130.  
  131. void alerting()
  132. {
  133.     printf("\n"
  134.     "\n"
  135.     "******************************\n"
  136.     "* Make sure to have a link to " BASE_PATH "/cb\n"
  137.     "******************************\n"
  138.     "\a\n"
  139.     );
  140. }
  141.  
  142. void man()
  143. {
  144.     chdir("man");
  145.     system("groff -Tascii -mandoc cb.1 | gzip > /var/man/cat1/cb.1.gz");
  146.     system("groff -Tascii -mandoc cblogin.1 | gzip > /var/man/cat1/cblogin.1.gz");
  147.     system("groff -Tascii -mandoc cbmgetty.1 | gzip > /var/man/cat1/cbmgetty.1.gz");
  148.     system("groff -Tascii -mandoc callback.4 | gzip > /var/man/cat4/callback.4.gz");
  149. }
  150.  
  151. void instprog (string prog, string destdir)
  152. {       
  153.     printf("\n"
  154.            "Installing ", prog, " in ", destdir, "\n");
  155.  
  156.     exec("chmod", "750", prog);
  157.     exec("cp", prog, destdir);
  158. }
  159.  
  160.  
  161. void dialin()
  162. {
  163.     printf("Installing for dial-in\n");
  164.  
  165.     instprog ("cb/cb", BASE_PATH);
  166.     alerting();
  167. }
  168.     
  169. void callback()
  170. {
  171.     printf("Installing for callback\n");
  172.  
  173.     instprog ("login/cblogin",   BASE_PATH);
  174.     instprog ("mgetty/cbmgetty", BASE_PATH);
  175.     dialin();
  176. }
  177.  
  178. int main(int argc, list argv)
  179. {       
  180.     string
  181.         arg;
  182.  
  183.     if (argc == 1)
  184.         usage();
  185.  
  186.     arg = element(1, argv);
  187.     
  188.     if (arg == "progs")
  189.         progs();
  190.     else if (arg == "tar")
  191.         tar();
  192.     else if (arg == "clean")
  193.         clean();
  194.     else if (arg == "man")
  195.         man();
  196.     else if (arg == "dist")
  197.         dist();
  198.     else if (arg == "install")
  199.     {
  200.         arg = element(2, argv);
  201.         
  202.         if (arg == "dial-in")
  203.             dialin();
  204.         else if (arg == "callback")
  205.             callback();
  206.         
  207.         return (0);
  208.     }
  209.     else
  210.         usage();
  211.  
  212.     return (0);
  213. }
  214.  
  215.